package Avanzado;

import Avanzado.net.*;

import java.io.*;

public class ClientMain
{

	public static void main(String[] args)
	{
		String server = "127.0.0.1";
		int port = 3317;
		
		SimpleClient client = null;
		BufferedReader in = null;
		
		try
		{
			client = new SimpleClient("127.0.0.1", 3317);
			
			in = new BufferedReader(new InputStreamReader(System.in));
			
			String message = "";
			
			while (message != "quit")
			{
				System.out.println(">");
				
				message = in.readLine();
				
				client.sendMessage(message);
			}
		}
		catch (IOException ex)
		{
			System.out.printf("No se puede conectar con: %s:%d\n", server, port);
		}
		finally
		{
			if (in != null)
			{
				try
				{
					in.close();
				}
				catch (Exception ex2)
				{
					ex2.printStackTrace();
				}
			}
			
			if (client != null)
			{
				try
				{
					client.close();					
				}
				catch (Exception ex2)
				{
					ex2.printStackTrace();
				}
			}
				
		}
	}

}
